/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.vfi.beans;

import edu.upn.sigemfi.ope.be.Ventanilla;
import edu.upn.sigemfi.vfi.bc.VentanillaDelegate;
import java.util.List;
import javax.faces.model.SelectItem;

/**
 *
 * @author Alex
 */
public class VentanillaController {

    private Ventanilla ventanilla;
    private VentanillaDelegate delegado;

    public VentanillaController() {
        delegado = new VentanillaDelegate();

    }

    public SelectItem[] getVentanillas() {
        SelectItem[] select = null;
        try {
            List<Ventanilla> lista = delegado.listar();
            if (lista != null) {
                select = new SelectItem[lista.size()];
                int i = 0;
//                select[i++] = new SelectItem(null, "<<Seleccione una Ventanilla");
                for (Ventanilla m : lista) {

                   // lista.add();
                    select[i++] = new SelectItem(m, "Ventanilla " + m.getIdVentanilla().toString());
                }
            } else {
                select = new SelectItem[1];
                select[0] = new SelectItem(null, "No existen Ventanillas");
            }
        } catch (Exception e) {

            select = new SelectItem[1];
            select[0] = new SelectItem(null, "<<Hubo un error>>" + e.getMessage());
        }
        return select;
    }

    /**
     * @return the ventanilla
     */
    public Ventanilla getVentanilla() {
        return ventanilla;
    }

    /**
     * @param ventanilla the ventanilla to set
     */
    public void setVentanilla(Ventanilla ventanilla) {
        this.ventanilla = ventanilla;
    }
}
